package com.ktjy.crm.model;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("sys_user") //指定表名
public class User implements Serializable {
    @TableId(type = IdType.AUTO) // 主键自增
    @TableField("usr_id") // 指定字段名
    private Long usrId;
    //乐观锁版本号字段
    @Version
    @TableField("version") // 确保与数据库字段名一致
    private Integer version; // 类型与数据库一致
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;
    @TableField("usr_name")
    private String usrName;
    private String usrPassword;
    private Long usrRoleId;
    private Integer usrFlag;
    @TableField(exist = false)
    private String roleName;
    //逻辑删除
    private Boolean deleted;

    public User(String usrName, String usrPassword, Long usrRoleId, Integer usrFlag) {
        this.usrName = usrName;
        this.usrPassword = usrPassword;
        this.usrRoleId = usrRoleId;
        this.usrFlag = usrFlag;
    }
}